#ifndef _COMMANDS_H_
#define _COMMANDS_H_

/* CONSTANTS */

// buffer sizes
#define CMD_BUF_SIZE 16

// command constants
#define TRAIN_SOLENOID_OFF  0x20
#define TRAIN_SW_STRAIGHT   0x21
#define TRAIN_SW_CURVED     0x22
#define TRAIN_REVERSE       0x0f
#define TRAIN_GO            0x60
#define TRAIN_STOP          0x61
#define TRAIN_SENSORS_BASE  0x80
#define TRAIN_SENSOR_BASE   0xc0

// other train set constants
#define NUM_SENSOR_MODULES  5

/* STATUS-TRACKING STRUCTS */

typedef struct __sensor {
  int set;
  int b1;
  int b2;
} sensor;

typedef struct __track {
  char tr_speed[81];
  char sw_dir[256];
  sensor ss_last;
} track;

typedef struct __event {
  int ii;
  char cc[10];
} event;

/* SHELL COMMAND FUNCTIONS */

void Tr(track *sts, int train_number, int train_speed);
void Rv(track *sts, int train_number);
void FlipSwitch(track *sts, int switch_number, char switch_direction);
void Sw(track *sts, int switch_number, char switch_direction);
void Stop(track *sts);
void Go(track *sts);

#endif // _COMMANDS_H_

